<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" href="fyicon.ico"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>飞扬报修系统</title>
<link href="__PUBLIC__/css/bootstrap.css" rel="stylesheet">
<link href="__PUBLIC__/css/style.css" rel="stylesheet">
<script type="text/javascript" src="__PUBLIC__/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
<!--[if lt IE 9]><script src="../../docs-assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>

<body>
<input type="hidden" id="account" value="@#$_GET['account']#@">
<input type="hidden" id="token" value="@#$_GET['token']#@">
 <div class="navbar navbar-fixed-bottom navbar-inverse" role="navigation">
       <div class="container">   
       	  <ul class="nav nav-pills">
            <li ><a href="__APP__/Home/Index/index?token=@#$_GET['token']#@&account=@#$_GET['account']#@">飞扬报修</a></li>
            <li class="active"><a href="__APP__/Home/IndexPage/order?token=@#$_GET['token']#@&account=@#$_GET['account']#@">查看订单</a></li>
            <li><a href="__APP__/Home/AccountPage/logout">退出</a></li>
          </ul>
       </div>
    </div>
<div class="container1">
	<br><center><h3>我的订单</h3></center>
	
<if condition="$count gt 0">

<foreach name="info" item="vo">

	<div class="jumbotron">
      <!--显示所有订单-->
    	<p class="text-success">订单号：@#$vo.number#@</p><!--订单号-->
    	<hr>
    	   <p>订单状态：<if condition="($vo.status eq 0) OR ($vo.status eq 5) ">
    	   待系统分配技术员请耐心等待技术员电话联系
    	               <elseif condition="$vo.status eq 1" />
						已分配技术员请耐心等待技术员电话联系
						<elseif condition="$vo.status eq 2" />
						该订单已取消
						<elseif condition="$vo.status eq 3" />
						待技术员维修
						<else />
						该订单已完成
						</if></p><!--订单状态-->
    	<p>电脑信息：@#$vo.brand#@@#$vo.model#@-@#$vo.buy_time|date="Y年m月",####@购买</p>
      	<p>报修原因：@#$vo.description#@</p><!--订单信息-->

<if condition="($vo.status eq 1) OR ($vo.status eq 3) OR ($vo.status eq 4)">
<p>技术员姓名：@#$vo.name#@</p>
<p>技术员联系方式：@#$vo.phone#@</p> 
</if>
    	
  		<hr><div align="right"><p> 
			<if condition="($vo.status eq 0) OR ($vo.status eq 1) OR ($vo.status eq 5) ">
			<span class="cancel_order"  ajaxid="@#$vo.order_id#@">
			<button class="btn btn-sm btn-default" id="cancel_order_@#$vo.order_id#@" type="button">取消订单</button>
			</span>		
			<elseif condition="$vo.status eq 3" />
			<span class="cancel_order" ajaxid="@#$vo.order_id#@">
			<button class="btn btn-sm btn-default" id="cancel_order_@#$vo.order_id#@" type="button">取消订单</button>
			</span>
			<span class="complete_order"  ajaxid="@#$vo.order_id#@">
			<button class="btn btn-sm btn-success" id="complete_order_@#$vo.order_id#@" type="button">确认已完成</button>
			</span>
			</if>
    	</div>
</div></p>
</foreach>
<div id="page">
@#$page#@
</div>
</p>
<else />
<p>当前无订单</p>
</if>
</div> 

<script type="text/javascript">
$(document).ready(function(){
	var account = $("#account").val();
	var token=$("#token").val();
	//用户取消订单
	$(".cancel_order").on("click",function(){	
		if(confirm("确认要取消该订单吗?")){			
			var order_id=$(this).attr('ajaxid');
			$("#cancel_order_"+order_id).text('处理中..');
			//alert(order_id);return;
			$.post("__APP__/Home/Handle/cancel?token="+token+'&account='+account, {order_id:order_id},//取消的订单号
				function(data){
					if(data.status==0){
						$("#cancel_order_"+order_id).text('取消失败,请重试');
						//document.location.reload("__APP__/Home/Index/order");
					}else{
						document.location.reload("__APP__/Home/IndexPage/order?token="+token+'&account='+account);//重新加载网页
					}
			});
		}
	});
	//用户点击确认完成订单
	$(".complete_order").on("click",function(){
		
		var order_id=$(this).attr('ajaxid');
		$("#complete_order_"+order_id).text('处理中..');
		//alert(order_id);return;
		$.post("__APP__/Home/Handle/complete?token="+token+'&account='+account,{order_id:order_id},
			function(data){
				if(data.status==0){
					$("#coplete_order_"+order_id).text('确认失败,请重试');
				}else{
					document.location.reload("__APP__/Home/IndexPage/order?token="+token+'&account='+account);
				}
			}
		);//完成的订单号		
	});
});
</script>
</body>
</html>
